<?php

namespace App\Service\Activity;

use App\Model\Act\WishTree;
use App\Model\Gift;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 许愿树信息
 */
class WishTreeInfoService extends BaseService
{
    public function handle()
    {
        $list = WishTree::getList(30);
        $tips = [];
        $userIds = array_column($list, 'user_id');
        $giftIds = array_column($list, 'wish_gift_id');
        $profiles = UserProfile::getUsersProfile($userIds, true);
        $giftInfo = Gift::getBatchInfo($giftIds);
        foreach ($list as $item) {
            $tips[] = [
                'nick_name' => $profiles[$item['user_id']]['nick_name'],
                'tip' => "向爱情树许愿，获得奖励 " . $giftInfo[$item['wish_gift_id']]['name'] . "*" . $item['num'],
            ];
        }
        $ret = [
            'wish_coin' => WishTree::WISH_COIN,
            'tips' => $tips,
        ];
        return $ret;
    }
}
